package cn.airfei.netty.nettyexample.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @description:
 * @author: air
 * @create: 2021-01-18 16:07
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        // 获取管道
        ChannelPipeline pipeline = ch.pipeline();
        // 添加http编解码器
        pipeline.addLast(new HttpServerCodec());
        // 添加自定义处理器
        pipeline.addLast(new TestHttpServerHandler());

    }
}
